package com.gzs.learn.payment.failover;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j
public class FailoverThread extends Thread {

    private final FailoverService failoverService;

    public FailoverThread(FailoverService service) {
        log.info("init failover service success");
        failoverService = service;
    }

    @Override
    public void run() {
        while (true) {
            try {
                failoverService.doRetry();
                TimeUnit.MILLISECONDS.sleep(100);
            } catch (final InterruptedException e) {
                log.warn("retry thread interrupt");
            }
        }
    }
}
